import { Subject } from 'rxjs';
import { UIActionTool, ViewTool } from '@/utils';
<#if !view_base_name??>
<#assign view_base_name = "ViewBase"/>
</#if>
import { ${view_base_name} } from '@/studio-core';
<#if view.getPSAppCounterRefs()??>
<#list view.getPSAppCounterRefs() as singleCounterRef>
<#if singleCounterRef.getPSAppCounter()??>
<#assign appCounter = singleCounterRef.getPSAppCounter()/>
import  ${srfclassname(appCounter.getCodeName())}CounterService  from '@/counter/${srffilepath2(appCounter.getCodeName())}/${srffilepath2(appCounter.getCodeName())}-counter';
</#if>
</#list>
</#if>
<#if view.getPSAppDataEntity?? && view.getPSAppDataEntity()??>
<#assign appde = view.getPSAppDataEntity()/>
import ${srfclassname(appde.getCodeName())}Service from '@/service/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-service';
import ${srfclassname(appde.getCodeName())}AuthService from '@/authservice/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-auth-service';
</#if>
<#if view.getPSAppViewEngines()??>
<#list view.getPSAppViewEngines() as engine>
import ${engine.getEngineType()}Engine from '@engine/${engine.getEngineCat()?lower_case}/${srffilepath2(engine.getEngineType())}-engine';
</#list>
</#if>
<#if view.getPSUIActions()??>
    <#list view.getPSUIActions() as uiAction>
        <#if uiAction.getPSAppDataEntity?? && uiAction.getPSAppDataEntity()??>
            <#if uiAction.getPFLogicCodeType() == "WFBACKEND">
                <#if uiAction.getPSAppWFVer?? && uiAction.getPSAppWFVer()??>
                    <#if !P.exists("importService", uiAction.getPSAppWFVer().getCodeName(), "")>
import ${srfclassname(uiAction.getPSAppWFVer().getCodeName())}WFUIService from '@/wfuiservice/${uiAction.getPSAppWF().getCodeName()?lower_case}/${uiAction.getPSAppWFVer().getCodeName()?lower_case}-ui-service';
                    </#if>
                </#if>
            <#else>
                <#assign curAppEntity = uiAction.getPSAppDataEntity()/>
                <#if !P.exists("importService1", curAppEntity.getId(), "")>
                <#if appde?? && (curAppEntity.getId() == appde.getId())><#assign hasAppDE = true /></#if>
import ${srfclassname(curAppEntity.getCodeName())}UIService from '@/uiservice/${srffilepath2(curAppEntity.getCodeName())}/${srffilepath2(curAppEntity.getCodeName())}-ui-service';
                </#if>
            </#if>
        </#if>
    </#list>
</#if>
<#if appde?? && !hasAppDE??>
import ${srfclassname(appde.getCodeName())}UIService from '@/uiservice/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-ui-service';
</#if>
<#if import_block??>
${import_block}
</#if>

/**
 * ${view.getTitle()}视图基类
 *
 * @export
 * @class ${srfclassname(view.name)}Base
 * @extends {${view_base_name}}
 */
export class ${srfclassname(view.name)}Base extends ${view_base_name} {
<#if view.getPSAppDataEntity?? && view.getPSAppDataEntity()??>
<#assign appde = view.getPSAppDataEntity()/>
    /**
     * 视图对应应用实体名称
     *
     * @protected
     * @type {string}
     * @memberof ${srfclassname(view.name)}Base
     */
    protected appDeName: string = '${appde.getCodeName()?lower_case}';
<#if appde.getKeyPSAppDEField?? && appde.getKeyPSAppDEField()??>

    /**
     * 应用实体主键
     *
     * @protected
     * @type {string}
     * @memberof ${srfclassname(view.name)}Base
     */
    protected appDeKey: string = '${appde.getKeyPSAppDEField().getName()?lower_case}';
<#else>
// ${view.warn('应用实体「' + appde.getCodeName() + '」未设置主键属性')}
</#if>
<#if appde.getMajorPSAppDEField?? && appde.getMajorPSAppDEField()??>

    /**
     * 应用实体主信息
     *
     * @protected
     * @type {string}
     * @memberof ${srfclassname(view.name)}Base
     */
    protected appDeMajor: string = '${appde.getMajorPSAppDEField().getName()?lower_case}';
<#else>
// ${view.warn('应用实体「' + appde.getCodeName() + '」未设置主文本属性')}
</#if>
<#if view.getXDataPSControl?? && view.getXDataPSControl()??>
<#assign dataControl = view.getXDataPSControl()/>

    /**
     * 数据部件名称
     *
     * @protected
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */ 
    protected dataControl:string = "${dataControl.name}";
</#if>

    /**
     * 实体服务对象
     *
     * @type {${srfclassname(appde.getCodeName())}Service}
     * @memberof ${srfclassname(view.name)}Base
     */
    protected appEntityService: ${srfclassname(appde.getCodeName())}Service = new ${srfclassname(appde.getCodeName())}Service;

    /**
     * 实体权限服务对象
     *
     * @type ${srfclassname(appde.getCodeName())}UIService
     * @memberof ${srfclassname(view.name)}Base
     */
    public appUIService: ${srfclassname(appde.getCodeName())}UIService = new ${srfclassname(appde.getCodeName())}UIService(this.$store);
</#if>
<#if view.getPSAppViewNavContexts()??>

	/**
	 * 自定义视图导航上下文集合
	 *
     * @protected
	 * @type {*}
	 * @memberof ${srfclassname(view.name)}Base
	 */
    protected customViewNavContexts: any = {
    <#list view.getPSAppViewNavContexts() as viewNavContext>
        '${viewNavContext.getKey()}': { isRawValue: ${viewNavContext.isRawValue()?c}, value: '${viewNavContext.getValue()}' }<#if viewNavContext_has_next>,</#if>
    </#list>
    };
</#if>
<#if view.getPSAppViewNavParams()??>

	/**
	 * 自定义视图导航参数集合
	 *
     * @protected
	 * @type {*}
	 * @memberof ${srfclassname(view.name)}Base
	 */
    protected customViewParams: any = {
    <#list view.getPSAppViewNavParams() as viewNavParam>
        '${viewNavParam.getKey()}': { isRawValue: ${viewNavParam.isRawValue()?c}, value: '${viewNavParam.getValue()}' }<#if viewNavParam_has_next>,</#if>
    </#list>
    };
</#if>
<#if view.isShowDataInfoBar?? && view.isShowDataInfoBar() == true>

    /**
     * 是否显示信息栏
     *
     * @memberof ${srfclassname(view.name)}Base
     */
    isShowDataInfoBar = true;
</#if>

    /**
     * 视图模型数据
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname(view.name)}Base
     */
    protected model: any = {
        srfCaption: '<#if view.getPSAppDataEntity()??>entities.${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${view.getCodeName()?lower_case}.caption</#if>',
        srfTitle: '<#if view.getPSAppDataEntity()??>entities.${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.title<#else>app.views.${view.getCodeName()?lower_case}.title</#if>',
        srfSubTitle: '<#if view.getPSAppDataEntity()??>entities.${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.subtitle<#else>app.views.${view.getCodeName()?lower_case}.subtitle</#if>',
        dataInfo: ''
    }

    /**
     * 容器模型
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname(view.name)}Base
     */
    protected containerModel: any = {
        <#if view.getPSControls()??>
        <#list view.getPSControls() as ctrl>
        view_${ctrl.name}: { name: '${ctrl.name}', type: '${ctrl.getControlType()}' },
        </#list>
        </#if>
        <#if view.isPickupView() || (view.getViewType?? && (view.getViewType() == 'DEOPTVIEW' || view.getViewType() == 'DEWFSTARTVIEW' || view.getViewType() == 'DEWFACTIONVIEW'))>
        view_okbtn: { name: 'okbtn', type: 'button', text: '确定', disabled: true },
        view_cancelbtn: { name: 'cancelbtn', type: 'button', text: '取消', disabled: false },
        view_leftbtn: { name: 'leftbtn', type: 'button', text: '左移', disabled: true },
        view_rightbtn: { name: 'rightbtn', type: 'button', text: '右移', disabled: true },
        view_allleftbtn: { name: 'allleftbtn', type: 'button', text: '全部左移', disabled: true },
        view_allrightbtn: { name: 'allrightbtn', type: 'button', text: '全部右移', disabled: true },
        </#if>
        <#if view.getPSWorkflow?? && view.getPSWorkflow()??>
        wflinks: [],
        </#if>
    };
<#list view.getAllPSControls() as controlItem>
<#if controlItem.getControlType() == "TOOLBAR">

${P.getCtrlCode(controlItem, 'CONTROL.vue').code}
</#if>
</#list>